import java.util.Map;
import java.util.Scanner;

public class demo12 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }
        long[][] dp = new long[n + 1][m + 1];
        long ret = Long.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + arr[i][j];
            }
        }
        for (int x1 = 1; x1 <= n; x1++) {
            for (int x2 = x1; x2 <= n; x2++) {
                for (int y1 = 1; y1 <= m; y1++) {
                    for (int y2 = y1; y2 <= m; y2++) {
                        long temp = sum(dp, x1, x2, y1, y2);
                        ret = Math.max(ret, temp);
                    }
                }
            }
        }
        System.out.println(ret);
    }

    public static long sum(long[][] dp, int x1, int x2, int y1, int y2) {
        long sum1 = dp[x2][dp[0].length - 1] - dp[x1-1][dp[0].length - 1];
        long sum2 = dp[dp.length - 1][y2] - dp[dp.length - 1][y1-1];
        long sum3 = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
        return sum1 + sum2 - sum3;
    }
}

